package edu.ynu.e_platform.common.entity;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author manwen Yang
 */
@Getter
@Setter
@MappedSuperclass  //标记为公共属性
@EntityListeners(AuditingEntityListener.class)  //监听实体的修改
public abstract class BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)  //设置主键为自增类型
    protected Long id;  //定义物理主键

    @Column(nullable = false)
    @CreatedDate
    protected Date createTime;

    @Column
    @LastModifiedDate
    protected Date updateTime;


}
